#!/usr/bin/env python
# _*_coding:utf-8 _*_
__author__ = "Gao"
from crm import models

def func1(request, *args, **kwargs):
    print('func1')
    print(args)
    print(kwargs)
    return True

def auth_studyrecords(request, enrollment_id,*args, **kwargs):
    '''学生只能查看自己的学习记录'''
    if request.user.stu_account.enrollment_set.filter(id=enrollment_id).exists():
        return True
    else:
        return False
    
    
def homework_detail(request, studyrecord_id,*args, **kwargs):
    '''学生只能查看自己的学习记录'''
    studyrecord_obj = models.StudyRecord.objects.filter(id=studyrecord_id).first()
    if studyrecord_obj:
        user_id = studyrecord_obj.student.customer.userprofile.id
        if user_id == request.user.id:
            return True
    return False


def delete_homework(request,*args, **kwargs):
    '''学生只能删除自己提交的作业'''
    return True